package jsave.action;

import java.io.File;

import jsave.exception.JSaveArretSauvegarde;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class ActionSupprimer extends Action {

	private static final Logger log = Logger.getLogger(ActionSupprimer.class);

	
	public ActionSupprimer(int typeAction) {
		
		super();
		
		if (typeAction == Action.ACTION_A || typeAction == Action.ACTION_B) {
			this.typeAction = typeAction;
		} else {
			log.log(Level.ERROR, "ERREUR - Le type d'action '"+typeAction+"' ne correspond pas a l'action 'ActionSupprimer' ");
		}
	}
	
	
	public void executer(File s, File d) throws JSaveArretSauvegarde {
		
		if (typeAction == ACTION_A) {
			if (s.isDirectory())
				supprimerDossier(s);
			else
				supprimerFichier(s);
		} else {
			if (d.isDirectory())
				supprimerDossier(d);
			else
				supprimerFichier(d);
		}
	}

	public String getNom() {
		return "SUPPRIMER";
	}
}
